const {ccclass, property} = cc._decorator;

@ccclass
export default class SpineRelease extends cc.Component {

    /** spine */
    @property({ type: sp.Skeleton, tooltip: 'spine' })
    spineNode: sp.Skeleton = null;

    start () {
        cc.log('加载前 assets =', cc.assetManager.assets);
    }

    onBtnReload() {
        cc.resources.load('spine/openboxAfter/skeleton', sp.SkeletonData, (error: Error, res: sp.SkeletonData) => {
            if (error) { cc.error(error); return; }
            
            this.spineNode.skeletonData = res;
            this.spineNode.setAnimation(0, '3', true);
            cc.log('加载后 assets =', cc.assetManager.assets);
        });
    }

    onBtnRemove() {
        cc.resources.release('spine/openboxAfter/skeleton', sp.SkeletonData);
        cc.log('移出后 assets =', cc.assetManager.assets);
    }

    onBtnChange() {
        // cc.resources.run
        cc.director.loadScene('helloworld');
    }
}
